<?php
class ProductController extends Zend_Controller_Action
{	
	public function indexAction()
    {
		$service = new ProductCategoryService();
		$data = $service->buildQueryData();
    	
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data);
    }
    
	public function listAction()
	{	
		$type = $this->getRequest()->getParam("type");
    	if(empty($type))
    	{
    		$this->_redirect("/index");exit;
    	}
    	$service = new ProductService();
    	$data = $service->getProductsWithType($type);
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,12);
	}
	
 	public function detailAction()
    {
    	//get detail of product
    	$id = $this->_getParam("id");
    	$service = new ProductService();
    	$product = $service->load($id);
    	$this->view->product = $product;
    	
    	//get other products
    	$data = $service->getOtherProducts($id);
    	$gui = $this->_helper->getHelper("Gui");
		$gui->showData($data,4);
    	
    	//increase hit count
//    	$product->hits += 1;
//    	$service->save($product);
    }
    
	
}
?>